package com.aurora.base.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.GenericGenerator;

import com.aurora.app.enums.FakeDelete;

@MappedSuperclass
public class BaseEntity implements Serializable {

	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = 7282576412687617289L;
	private String id;
	private Date createTime = new Date();
	private FakeDelete isDelete = FakeDelete.NODELETE; 
	private Date updateTime = new Date();;

	
	// ------------------------------- mysql -------------------------------- //
	/**
	 * @return the id
	 */
	/*@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="F_ID")
	public Long getId() {
		return id;
	}*/
	
	
	// -------------------------- oracle -------------------------------- //
	/*@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "songSequenceGenerator")
	@SequenceGenerator(
	      name = "songSequenceGenerator",
	      sequenceName = "song_sequence",
	      initialValue = 2,
	      allocationSize = 20
	  )
	@Column(name="F_ID")
	public Long getId() {
		return id;
	}*/

	// --------------------------- UUID  ----------------------------------- //
	@Id
	@GeneratedValue(generator = "tableGenerator")
	@GenericGenerator(name = "tableGenerator", strategy = "uuid")
	@Column(name ="f_id",nullable=false,length=32,unique=true)
	public String getId() {
		return id;
	}
	/**
	 * @param id the id to set
	 */
	public void setId(String id) {
		this.id = id;
	}
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "f_create_time")
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	@Enumerated(EnumType.ORDINAL)
	@Column(name = "f_isDelete")
	public FakeDelete getIsDelete() {
		return isDelete;
	}
	
	public void setIsDelete(FakeDelete isDelete) {
		this.isDelete = isDelete;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "f_update_time")
	public Date getUpdateTime() {
		return updateTime;
	}
	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
}